﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EditQuestion.aspx.cs" Inherits="PollSystem.Registered.EditQuestion" %>

<asp:Content ID="ContentEditQuestion" ContentPlaceHolderID="MainContent" runat="server">

    <h3>Question:</h3>

    <asp:TextBox ID="TextBoxEditQuestion" runat="server"></asp:TextBox>
    <asp:LinkButton Text="Save" runat="server" ID="LinkButtonSave"
        OnClick="LinkButtonSaveQuestion_Click" />

    <asp:LinkButton Text="Cancel" runat="server" ID="LinkButtonCancel"
        OnClick="LinkButtonCancelEdit_Click" />

    <asp:LinkButton Text="Delete" runat="server" ID="LinkButtonDelete"
        OnClick="LinkButtonDelete_Click" />

    <asp:RequiredFieldValidator ID="RequiredFieldValidatorEmptyBox" runat="server"
        ControlToValidate="TextBoxEditQuestion"
        ErrorMessage="Enter question please."
        ForeColor="Red">
    </asp:RequiredFieldValidator>
    <br />

    <ul>
        <asp:Repeater ID="RepeaterAnswers" runat="server"
            ItemType="PollSystem.Model.Answer">
            <ItemTemplate>
                <li>
                    <%#: Item.AnswerText %> - <%#: Item.Votes %>
                    <a href="EditAnswer.aspx?answerId=<%# Item.AnswerId %>">Edit</a>
                    <asp:LinkButton Text="Delete" runat="server"
                        CommandName="Delete"
                        CommandArgument="<%# Item.AnswerId %>"
                        OnCommand="DeleteAnswer_Command" />
                </li>
            </ItemTemplate>
        </asp:Repeater>
    </ul>

    <asp:LinkButton Id="LinkButtonShowCreateAnswerForm" 
        Text="Create New Answer" 
        runat="server" 
        OnClick="ShowCreateNewAnswerForm_Click"/>

    <asp:FormView ID="FormViewCreateAnswer" runat="server"
        DefaultMode="Insert"
        Visible="false">

        <EmptyDataTemplate>
            <div>Empty.</div>
        </EmptyDataTemplate>

        <InsertItemTemplate>
            <h5>Answer:
                <asp:TextBox ID="TextBoxAnswer" runat="server" ViewStateMode="Disabled"/>
                <br />
                Votes:
                <asp:TextBox ID="TextBoxVotes" runat="server" ViewStateMode="Disabled" />
            </h5>
            <asp:LinkButton ID="LinkButtonSave" Text="Save" runat="server" OnClick="LinkButtonSave_Click" />
            <asp:LinkButton ID="LinkButtonCancel" Text="Cancel" runat="server" OnClick="LinkButtonCancel_Click" />
        </InsertItemTemplate>

    </asp:FormView>

</asp:Content>
